<script>
import api from '@/api/index'

export default {
  name: "index",
  data() {
    return {
      total: 0,
      tableData: [],
      queryParam: {
        pageSize: 2,
        pageNum: 1
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      let data = await api.xing_zheng_gui_fan_list(this.queryParam);
      console.log('>>>>>>>>>>>data', data)
      this.tableData = data.records;
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>

<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-table
            :show-header="false"
            :data="tableData"
            style="width: 100%">
          <el-table-column
              show-overflow-tooltip
              label="下载">
            <template #default="{row}">
              <div class="p-3">

                <router-link :to="`/xing_zheng_gui_fan_wen_jian/detail?id=${row.id}`"><div class="text-lg text-black">{{row.title}}</div></router-link>
                <div class="flex justify-between">
                  <span class="py-1">发文机构：<span>{{row.department}}</span></span>
                  <span class="py-1">文号：<span>{{row.articleNo}}</span></span>
                  <span class="py-1">发文日期：<span>{{row.createdAt}}</span></span>
                </div>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="24" class="mt-2 flex justify-center">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="queryParam.pageNum"
            :page-sizes="[5,10,20]"
            :page-size="queryParam.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>

</style>
